using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace GraphFS
{
	public class GraphDraw
	{

		/// <summary>
		/// 
		/// </summary>
		/// <param name="graph"><see cref="FSGraph"/></param>
		/// <param name="lod">level of detail 1->128TBD</param>
		/// <param name="zoom">zoom level 1->128TBD</param>
		/// <param name="nodeId">center node</param>
		/// <param name="g"><see cref="System.Drawing.Graphics"/></param>
		/// <param name="rect"><see cref="System.Drawing.Rectangle"/></param>
		public static void DrawGraph(FSGraph graph, int lod, int zoom, Int64 nodeId, Graphics g, Rectangle rect)
		{
			double mainScale = 1000;// scale 1:1 <=> 1gr=100px;
			double scale = mainScale * zoom;
			FSNode n = graph.GetNode(nodeId);

			
			double w = rect.Width / scale;
			double h = rect.Height / scale;
			double lat = n.Location.Lat - w / 2;
			double lon = n.Location.Lon - h / 2;
			GeoRectangle r=new GeoRectangle(lat,lon,w,h);


			//look into waysBounds and extract only ways that intersect the rect
			//apply lod filtering



			List<FSNode> nodes=graph.GetNodes(r);
			//Console.WriteLine(nodes.Count);

			foreach (FSNode nd in nodes)
			{
				GeoSize p = nd.Location - r.Location;
				p.Width=p.Width*scale;
				p.Height=p.Height*scale;
				//Console.WriteLine("{0} {1}", p.Width * scale, p.Height * scale);

				g.FillEllipse(Brushes.Black, (float) p.Width - 1, (float) p.Height - 1, 2,2);

			}




			//get graph wise bound rect (zoom,nodeId,[lod])
			//get graph wise sectors intersect rect, zoom
			//foreach sector draw all nodes, edges


		}



	}
}
